home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / raid / devRaid.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  4.7 KB  |  179 lines

  1. /* 
  2.  * devRaid.h --
  3.  *
  4.  *    Declarations for RAID device drivers.
  5.  *
  6.  * Copyright 1989 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * $Header: /cdrom/src/kernel/Cvsroot/kernel/raid/devRaid.h,v 1.11 92/06/25 17:20:55 eklee Exp $ SPRITE (Berkeley)
  16.  */
  17.  
  18. #ifndef _DEVRAID
  19. #define _DEVRAID
  20.  
  21. #include "sprite.h"
  22. #include "sync.h"
  23. #include "fs.h"
  24. #include "devBlockDevice.h"
  25. #include "devRaidDisk.h"
  26. #include "devRaidLog.h"
  27.  
  28. #ifndef MIN
  29. #define MIN(a,b) ( (a) < (b) ? (a) : (b) )
  30. #endif  MIN
  31.  
  32. #ifndef MAX
  33. #define MAX(a,b) ( (a) > (b) ? (a) : (b) )
  34. #endif  MAX
  35.  
  36. #define BITS_PER_ADDR            32
  37. #define RAID_MAX_XFER_SIZE        (1<<30)
  38. #ifdef TESTING
  39. #define RAID_ROOT_CONFIG_FILE_NAME    "RAID"
  40. #else
  41. #define RAID_ROOT_CONFIG_FILE_NAME    "/ra/raid/RAID"
  42. #endif TESTING
  43.  
  44. /*
  45.  * Data structure each RAID device.
  46.  *
  47.  * RAID_INVALID    ==> Array has not been configured.
  48.  * RAID_ATTACHED==> Array attached but not configured.
  49.  * RAID_VALID    ==> Array is configured and ready to service requests.
  50.  */
  51. typedef enum { RAID_INVALID, RAID_ATTACHED, RAID_VALID } RaidState;
  52.  
  53. typedef struct Raid {
  54.     RaidState         state;        /* must be first field */
  55.     Sync_Semaphore     mutex;        /* must be second field */
  56.     Sync_Condition     waitExclusive;
  57.     Sync_Condition     waitNonExclusive;
  58.     int             numReqInSys; /* -1 => exclusive access */
  59.     int             numWaitExclusive; /* number waiting for */
  60.                       /* exclusive access. */
  61.  
  62.     Fs_Device        *devicePtr; /* Device corresponding to this raid. */
  63.     int             numCol;
  64.     int             numRow;
  65.     RaidDisk          ***disk;        /* 2D array of disks (column major) */
  66.  
  67.     RaidLog         log;
  68.  
  69.     unsigned         numSector;
  70.     int              numStripe;
  71.     int             dataSectorsPerStripe;
  72.     int             dataStripeUnitsPerDisk;
  73.     int              sectorsPerDisk;
  74.     int              bytesPerStripeUnit;
  75.     int              dataBytesPerStripe;
  76.  
  77.     int              numDataCol;
  78.     int              logBytesPerSector;
  79.     int              bytesPerSector;
  80.     int              sectorsPerStripeUnit;
  81.     int              rowsPerGroup;
  82.     int              stripeUnitsPerDisk;
  83.     int              groupsPerArray;
  84.     char         parityConfig;
  85. } Raid;
  86.  
  87. /*
  88.  * RaidHandle.
  89.  */
  90. typedef struct RaidHandle {        /* Subclass of DevBlockDeviceHandle. */
  91.     DevBlockDeviceHandle blockHandle;    /* Must be FIRST field. */
  92.     Fs_Device        *devPtr;    /* Device corresponding to handle */
  93.     Raid        *raidPtr;
  94. } RaidHandle;
  95.  
  96. /*
  97.  * RaidBlockRequest
  98.  *
  99.  * REQ_INVALID    ==> the request is to a failed device
  100.  * REQ_FAILED    ==> an error code was returned by the device
  101.  * REQ_READY    ==> the request is ready to be issued
  102.  * REQ_COMPLETED==> the request has successfully completed
  103.  * REQ_PENDING     ==> the request has been issued and is waiting for completion
  104.  */
  105. typedef enum RaidBlockRequestState {    /* Subclass of DevBlockDeviceRequest */
  106.     REQ_INVALID, REQ_FAILED, REQ_READY, REQ_COMPLETED, REQ_PENDING
  107. } RaidBlockRequestState;
  108.  
  109. typedef struct RaidBlockRequest {
  110.     DevBlockDeviceRequest devReq;
  111.     RaidBlockRequestState state;
  112.     ReturnStatus      status;
  113.     Raid         *raidPtr;
  114.     int              col;
  115.     int              row;
  116.     RaidDisk         *diskPtr;
  117.     int              version;
  118. } RaidBlockRequest;
  119.  
  120. /*
  121.  * Raid Control structures for syncronizing/communicating with
  122.  * interrupt routines.
  123.  */
  124. typedef struct RaidIOControl {
  125.     Sync_Semaphore     mutex;
  126.     Raid        *raidPtr;
  127.     int             numIO;
  128.     void           (*doneProc)();
  129.     ClientData         clientData;
  130.     ReturnStatus     status;
  131.     int             amountTransferred;
  132.     int             numFailed;
  133.     RaidBlockRequest    *failedReqPtr;
  134. } RaidIOControl;
  135.  
  136. typedef struct RaidRequestControl {
  137.     RaidBlockRequest    *reqPtr;
  138.     int             numReq;
  139.     int             numFailed;
  140.     RaidBlockRequest    *failedReqPtr;
  141. } RaidRequestControl;
  142.  
  143. typedef struct RaidStripeIOControl {
  144.     Raid        *raidPtr;
  145.     int             operation;
  146.     unsigned         firstSector;
  147.     unsigned         nthSector;
  148.     Address         buffer;
  149.     void           (*doneProc)();
  150.     ClientData         clientData;
  151.     void           (*recoverProc)();
  152.     int             ctrlData;
  153.     RaidRequestControl    *reqControlPtr;
  154.     char        *parityBuf;
  155.     char        *readBuf;
  156.     int             rangeOff;
  157.     int             rangeLen;
  158. } RaidStripeIOControl;
  159.  
  160. typedef struct RaidReconstructionControl {
  161.     Raid        *raidPtr;
  162.     int             col;
  163.     int             row;
  164.     RaidDisk        *diskPtr;
  165.     int             stripeID;
  166.     int             numStripe;
  167.     void           (*doneProc)();
  168.     ClientData         clientData;
  169.     int             ctrlData;
  170.     RaidRequestControl    *reqControlPtr;
  171.     ReturnStatus     status;
  172.     char        *parityBuf;
  173.     char        *readBuf;
  174. } RaidReconstructionControl;
  175.  
  176. extern DevBlockDeviceHandle *DevRaidAttach _ARGS_((Fs_Device *devicePtr));
  177.  
  178. #endif _DEVRAID
  179.